package com.anxin.controller;

import com.anxin.entity.Registration;
import com.anxin.service.RegistrationService;
import com.anxin.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@Tag(name = "挂号管理")
@RestController
@RequestMapping("/api/registration")
public class RegistrationController extends BaseController {
    @Autowired
    private RegistrationService registrationService;

    @Operation(summary = "根据ID获取挂号信息")
    @GetMapping("/{id}")
    public Result<Registration> getById(@Parameter(description = "挂号ID") @PathVariable String id) {
        return Result.success(registrationService.getById(id));
    }

    @Operation(summary = "获取挂号列表")
    @GetMapping("/list")
    public Result<List<Registration>> list() {
        return Result.success(registrationService.list());
    }

    @Operation(summary = "保存或更新挂号信息")
    @PostMapping("/save")
    public Result<Boolean> save(@RequestBody Registration registration) {
        return Result.success(registrationService.saveOrUpdate(registration));
    }

    @Operation(summary = "删除挂号信息")
    @DeleteMapping("/{id}")
    public Result<Boolean> delete(@Parameter(description = "挂号ID") @PathVariable String id) {
        return Result.success(registrationService.removeById(id));
    }
}
